﻿<?php
  @header("content-Type: text/html; charset=utf-8"); //语言强制

  $stockCode = $_GET['code'];
  // Connect to the database 
  $dbc = mysqli_connect('localhost', 'root', 'k00l@1D;', 'gudahu')
    or die('Error connecting to MySQL server.');
	mysqli_set_charset($dbc, 'utf8');
  $query = "SELECT name FROM stock where code = ".$stockCode;
  $result = mysqli_query($dbc, $query)
    or die('Error querying database.'); 
  $stockName = '';  
  if ($row = mysqli_fetch_array($result)) {
      $stockName = $row['name']; 
  } 
  
  mysqli_close($dbc);
  
  $specialTitle = $stockName.'('.$stockCode.')前十大流通股股东';  
  
	require_once('head.php');
?>

<link rel="stylesheet" href="/css/table.css" type="text/css"/>
<br/>
<table class="t1"> 
 
<?php
  echo '<thead><th colspan="4">'.$stockCode.'-'.$stockName.'</th></thead>';
              
  // Retrieve the score data from MySQL
  $dbc = mysqli_connect('localhost', 'root', 'k00l@1D;', 'gudahu')
    or die('Error connecting to MySQL server.');
	mysqli_set_charset($dbc, 'utf8');
  $query = "SELECT * FROM top_holder where stock_code = ".$stockCode.' order by appear_date desc, id asc';
  $result = mysqli_query($dbc, $query)
    or die('Error querying database.'); 
  $appearDate = '';
  $isLine2 = false;  
  while ($row = mysqli_fetch_array($result)) { 
  	  $currentAppearDate = $row['appear_date'];
  	  if ($currentAppearDate != $appearDate) {
  	  	echo '<tr><td colspan="4">&nbsp;</td></tr>';
  	  	echo '<tr><td colspan="4">'.$currentAppearDate.'</td></tr>';	  	
  	  	echo '<tr><td>排名</td><td>股东</td><td>占股数量</td><td>占股比例</td></tr>';
  	  	$appearDate = $currentAppearDate;
  	  	$isLine2 = false;
  	  }
  	  
  	  if ($isLine2) {
  	  	echo '<tr class="a1">';
  	  	$isLine2 = false;
  	  } else {
  	  	echo '<tr>';
  	  	$isLine2 = true;
  	  }
  	  
      echo '<td>'.$row['rank'].'</td>';
      echo '<td><a target="_blank" href="http://gudahu.com/hotKeyword.php?keyword='.$row['holder_name'].'">'.$row['holder_name'].'</a></td>';
      echo '<td>'.$row['share_amount'].'</td>';
      echo '<td>'.$row['share_ratio'].'%</td>';
      echo '</tr>';
  }					    
  mysqli_close($dbc);
?>

</table>

<?php
	require_once('foot.php');
?>  
